/*
 * \brief  Dataspace client interface
 * \author Norman Feske
 * \date   2006-05-11
 */

/*
 * Copyright (C) 2006-2009 Norman Feske
 * Genode Labs, Feske & Helmuth Systementwicklung GbR
 *
 * This file is part of the Genode OS framework, which is distributed
 * under the terms of the GNU General Public License version 2.
 */

#ifndef _INCLUDE__DATASPACE__CLIENT_H_
#define _INCLUDE__DATASPACE__CLIENT_H_

#include <dataspace/capability.h>
#include <base/ipc.h>
#include <base/lock.h>

namespace Genode {

	class Dataspace_client : public Dataspace
	{
		protected:

			Msgbuf<256> _snd_msg, _rcv_msg;
			Ipc_client  _ds;
			Lock        _lock;

		public:

			/**
			 * Constructor
			 */
			explicit Dataspace_client(Dataspace_capability ds)
			: _ds(ds, &_snd_msg, &_rcv_msg) { }


			/*************************
			 ** Dataspace interface **
			 *************************/

			size_t size()
			{
				Lock::Guard lock_guard(_lock);
				size_t result = 0;
				_ds << SIZE << IPC_CALL >> result;
				return result;
			}

			addr_t phys_addr()
			{
				Lock::Guard lock_guard(_lock);
				addr_t addr = 0;
				_ds << PHYS_ADDR << IPC_CALL >> addr;
				return addr;
			}
	};
}

#endif /* _INCLUDE__DATASPACE__CLIENT_H_ */
